﻿/*
    File name:          Conveyer
    File type:          Class
    Author:             Sune Krog-Meyer 09888
    Creation date:      03-04-2011
    Description:        Contains conveyerfunktions for the robot.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using i4pro_gruppe_d.ControllerCommunication;
using i4pro_gruppe_d.RobotCommunication;
using i4pro_gruppe_d.SimulatorAdaptor;

namespace i4pro_gruppe_d.Hardware
{
    public class Conveyer
    {
        private readonly IControllerCommunication _conveyer;

        /// <summary>
        /// Classconstructor
        /// </summary>
        /// <param name="physical"> True if robot, false if simulator </param>
        public Conveyer(bool physical)
        {
            if(physical)
            {
                _conveyer = new ConcreteDLLAdaptor();          
            }
            else
            {
                _conveyer = new ConcreteSimulatorAdaptor();
            }
        }

        /// <summary>
        /// Starts the conveyerbelt
        /// </summary>
        /// <param name="speed"> Speed of the conveyerbelt (+/- 0-100) </param>
		public void Start(int speed = -70)
		{
			Console.WriteLine(_conveyer.startConveyer(speed) ? "Conveyer Start: Succes" : "Conveyer Start: Failed");
		}

        /// <summary>
        /// Stops the conveyerbelt
        /// </summary>
		public void Stop()
		{
			Console.WriteLine(_conveyer.stopConveyer() ? "Conveyer Stop: Succes" : "Conveyer Stop: Failed");
		    _conveyer.closeManualMode();
		}

        /// <summary>
        /// Returns if movement is in progress
        /// </summary>
        /// <returns> True if a new movement can be startet, false otherwise </returns>
        public bool CheckMotionStatus()
        {
            return _conveyer.GetMotionStatus();
        }
    }
}
